<?php if (!empty($photo_user->id)): ?>
<section id="content">
  <div class="block">
    <header>      
      <h2>Upravit <?php echo $photo_user->title; ?></h2>
    </header>
    <section class="block-body">
      <form action="<?php echo url::base(); ?>photo/edit/<?php echo $photo_user->id ?>" method="post">
        <fieldset>
          <ul>
            <li>
              <label for="title">Název fotografií:</label>
              <input type="text" id="title" name="title" value="<?php echo $photo_user->title ?>" class="text" />
            </li>
            <li>
              <label for="description">Popis:</label>
              <textarea cols="10" rows="10" name="description" class="text" ><?php echo $photo_user->description ?></textarea>
            </li>
            <li>
              <label for="tags">Tagy:</label>
              <div id="container-tags">
                <input id="tags" type="text" name="tags" value="" class="text" />
                <span class="top-right2"><a href="javascript:;" id="tag-add" class="button-dark" title="">+</a></span>
              </div>
              <div id="dialog-confirm">
                <p>Skutečně chcete tento tag odtranit?</p>
              </div>
              <?php $i = 123456; foreach ($photo_user->photo_tag->find_all() as $item): ?>
                <label class="text-tags" id="tag<?php echo $i; ?>">
                  <input type="hidden" value="<?php echo $item->tag; ?>" name="tags[]" readonly="readonly"><?php echo $item->tag; ?>
                  <a title="Odstranit" class="href-gray" onclick="tagDelete(<?php echo $i; ?>,<?php echo $item->id; ?>)" href="javascript:;">(x)</a>
                </label>
              <?php $i++; endforeach ?>
            </li>
            <li>
              <label for="user_profile_allowed">Umístit pouze na profil:</label>        <input type="checkbox" id="user_profile_allowed" name="user_profile_allowed" value="1" />
            </li>
            <li>
              <label for="user_comments_allowed">Povolit komentáře:</label>        <input type="checkbox" id="user_comments_allowed" name="user_comments_allowed" value="1" checked="checked" />
            </li>
            <li>
            <input type="submit" name="form-submit" value="Upravit"  />
            </li>
          </ul>
        </fieldset>
      </form>      
    </section>
  </div>
  <div class="block-bottom"></div>
</section>
<script>
  $(function() {
    $( "#dialog-confirm" ).hide();
  });

  function tagDelete(number,id) {
    $( "#dialog-confirm" ).dialog({
      resizable: false,
      width: 400,
      minHeight: 40,
      modal: true,
      draggable: false,
      closeOnEscape: true,
      open: function(event, ui) { $(".ui-dialog-titlebar-close,.ui-dialog-titlebar").remove(); },
      buttons: {
        "Odstranit": function() {          
          $('#tag'+number+'').remove();
          $( this ).dialog( "close" );
        },
        "Zavřít": function() {
          $( this ).dialog( "close" );
        }
      }
    });
  }
</script>
<?php endif ?>

